package com.kasinf.sample.sky.controller;

import com.kasinf.framework.common.pojo.PageParam;
import com.kasinf.framework.common.pojo.PageResult;
import com.kasinf.sample.sky.entity.ApiLogEsDO;
import com.kasinf.sample.sky.mapper.ApiLogEsMapper;
import jakarta.annotation.Resource;
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author : Kaiser
 * @Date: 2025/7/8  09:08
 */
@RestController
@RequestMapping("demo")
public class DemoController {

    @Resource
    private ApiLogEsMapper apiLogEsMapper;


    @GetMapping("elastic")
    public PageResult<ApiLogEsDO> elastic() {
        LambdaEsQueryWrapper<ApiLogEsDO> queryWrapper = new LambdaEsQueryWrapper<>();
        queryWrapper.indexName("sample_api_log_202507");
        queryWrapper.eq(ApiLogEsDO::getApplicationName, "log-client-sample");
        PageParam pageParam = new PageParam();
        pageParam.setPageNo(1);
        pageParam.setPageSize(10);
        return apiLogEsMapper.selectPage(pageParam, queryWrapper);
    }
}
